package com.sdhs.basicinfo.controller;


import com.sdhs.basicinfo.domain.GcFoundationQuickModule;
import com.sdhs.basicinfo.service.IGcFoundationQuickModuleService;
import com.sdhs.common.core.controller.BaseController;
import com.sdhs.common.core.domain.AjaxResult;
import com.sdhs.common.core.page.TableDataInfo;
import com.sdhs.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 快速入口配置Controller
 *
 * @author add
 * @date 2025-01-01
 */
@RestController
@RequestMapping("/quick/module")
public class GcFoundationQuickModuleController extends BaseController {

    @Autowired
    private IGcFoundationQuickModuleService gcFoundationQuickModuleService;

    /**
     * 查询快速入口配置列表
     */
    @PreAuthorize("@ss.hasPermi('quick:module:list')")
    @GetMapping("/list")
    public TableDataInfo list(GcFoundationQuickModule gcFoundationQuickModule) {
        startPage();
        List<GcFoundationQuickModule> gcFoundationQuickModules = gcFoundationQuickModuleService.selectProcureQuickModuleList(gcFoundationQuickModule);
        return getDataTable(gcFoundationQuickModules);
    }

    /**
     * 查询快速入口配置列表-不分页
     */
    @PreAuthorize("@ss.hasPermi('quick:module:onlyList')")
    @GetMapping("/onlyList")
    public AjaxResult onlyList(GcFoundationQuickModule gcFoundationQuickModule) {
        List<GcFoundationQuickModule> gcFoundationQuickModules = gcFoundationQuickModuleService.selectProcureQuickModuleList(gcFoundationQuickModule);
        return success(gcFoundationQuickModules);
    }

    /**
     * 导出快速入口配置列表
     */
    @PreAuthorize("@ss.hasPermi('quick:module:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, GcFoundationQuickModule gcFoundationQuickModule) {
        List<GcFoundationQuickModule> gcFoundationQuickModules = gcFoundationQuickModuleService.selectProcureQuickModuleList(gcFoundationQuickModule);
        ExcelUtil<GcFoundationQuickModule> util = new ExcelUtil<GcFoundationQuickModule>(GcFoundationQuickModule.class);
        util.exportExcel(response, gcFoundationQuickModules, "快速入口配置数据");
    }

    /**
     * 获取快速入口配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('quick:module:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(gcFoundationQuickModuleService.selectProcureQuickModuleById(id));
    }

    /**
     * 新增快速入口配置
     */
    @PreAuthorize("@ss.hasPermi('quick:module:add')")
    @PostMapping
    public AjaxResult add(@RequestBody GcFoundationQuickModule gcFoundationQuickModule) {
        return toAjax(gcFoundationQuickModuleService.insertProcureQuickModule(gcFoundationQuickModule));
    }

    /**
     * 修改快速入口配置
     */
    @PreAuthorize("@ss.hasPermi('quick:module:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody GcFoundationQuickModule gcFoundationQuickModule) {
        return toAjax(gcFoundationQuickModuleService.updateProcureQuickModule(gcFoundationQuickModule));
    }

    /**
     * 删除快速入口配置
     */
/*    @PreAuthorize("@ss.hasPermi('quick:module:remove')")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(gcFoundationQuickModuleService.deleteProcureQuickModuleByIds(ids));
    }*/
    /**
     * 获取快速入口配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('quick:module:delete')")
    @DeleteMapping( "/{id}")
    public AjaxResult delete(@PathVariable("id") Long id) {
        return success(gcFoundationQuickModuleService.deleteProcureQuickModuleById(id));
    }
}
